﻿/*  ----------------------------------------------------------------------------
 *  SysServer
 *  ----------------------------------------------------------------------------
 *  File:       SyncExtend.cs
 *  Creater:     SEEN\MistSeen
 *  ----------------------------------------------------------------------------
 *  $Date: 2010-09-06 10:36:01 +0000 (Mon, 06 Sep 2010) $
 *  $Rev: 15 $
 *  $Author: ScorDeity $
 *  $URL: http://sysserver.googlecode.com/svn/trunk/src/SysServer/SyncExtend.cs $
 *  $Id: SyncExtend.cs 15 2010-09-06 10:36:01Z ScorDeity $
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace SysServer
{
    /// <summary>
    /// 异步对象的扩展
    /// </summary>
    public static class SyncEx
    {
        public static bool CompareExchange<T>(ref T location, T comparand, T newValue)
            where T : class
        {
            return object.ReferenceEquals(comparand, Interlocked.CompareExchange<T>(ref location, newValue, comparand));
        }
    }
}